﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B4
{
    interface Idiagram
    {
        bool isLegal();
        double getArea();
    }
    class Triangle:Idiagram
    {
        public double pin1 { set; get; }
        public double pin2 { set; get; }
        public double pin3 { set; get; }
        public  Triangle(double pin1,double pin2,double pin3)
        {
            this.pin1 = pin1;
            this.pin2 = pin2;
            this.pin3 = pin3;
        }
        public bool isLegal()
        {
            if (pin1 == 0|| pin2 == 0 || pin3 == 0) { return false; }
            if (pin1 + pin2 <= pin3) { return false; }
            if (pin3 + pin2 <= pin1) { return false; }
            if (pin1 + pin3 <= pin2) { return false; }
            return true;
        }
        public double getArea()
        {
            if (isLegal())
            {
                double d = (pin1 + pin2 + pin3) / 2.0;
                return Math.Sqrt(d * (d - pin1) * (d - pin2) * (d - pin3));
            }
            return -1;
        }
    }
    class Rectangle:Idiagram{
        public Rectangle(double len,double wid)
        {
            this.len = len;
            this.wid = wid;
        }
        public double len { set; get; }
        public double wid { set; get; }
        public bool isLegal()
        {
            if (len == 0 || wid == 0) { return false; }
            return true;
        }
        public  double getArea()
        {
            if (isLegal()) { return len * wid; }
            return -1;
        }
    }
    class Square : Idiagram {
        public Square(double side)
        {
            this.side = side;
        }
        public  double side{ set; get; }
        public bool isLegal()
        {
            if (side == 0 ) { return false; }
            return true;
        }
        public double getArea()
        {
            if (isLegal()) { return side * side; }
            return -1;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            //Square s1 = new Square(3.2);
            //Console.WriteLine(s1.side.ToString());
            //Console.WriteLine(s1.getArea().ToString());
            //Console.ReadLine();
        }
    }
}
